<?php
error_reporting("E_ALL^E_NOTICE");
session_start();
include './function/Tampil2.php';
?>
<html>
    <head>
        <meta name="key/words" content="berbagi,charity,community"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/bootstrap.css">       
        <link rel="stylesheet" href="style.css">   
        <title>Semua Berbagi - Indonesia Charity Community</title>
    </head>
    <body onload="changePagination('0', 'first')">
        <?php
        if (isset($_SESSION['user'])) {
            $status = $_SESSION['user']['status'];
        } else {
            include './masuk.php';
            exit();
        }
        if (isset($_SESSION['testi'])) {
            echo '<script>alert("' . $_SESSION['testi'] . '")</script>';
            unset($_SESSION['testi']);
        }
        $t = new Tampil2();
        ?>
        <div class="container">
            <div class="navbar navbar-default" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed togle_margin" data-toggle="collapse" data-target=".navbar-collapse"> 
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                        </button> 
                        <form class="navbar-form" role="search">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="Search" name="text_search">
                                <div class="input-group-btn">
                                    <button class="btn btn-default buttonCari" type="submit" name="button_search"><i class="glyphicon glyphicon-search"></i></button>
                                </div>
                            </div>
                        </form>
                    </div> 
                    <div class="navbar-collapse collapse"> 
                        <ul class="nav navbar-nav navbar-right">
                            <li>
                                <a href="index.php">    Beranda    |</a>
                            </li>
                            <li>
                                <a href="clearsession.php">Logout</a>
                            </li> 
                        </ul>                        
                        <div class="navbar-text navbar-right">Masuk sebagai <?php echo $status ?>     |</div>
                    </div> 
                </div>
            </div>

            <div class="jumbotron utama">
                <div class="row">
                    <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
                        <!--<img src="img/logo.png" class="img-responsive im"/>-->
                        <ul class="nav nav-pills nav-stacked menu">
                            <li>
                                <a href="uploadBarang.php"><small>Unggah Barang</small></a>
                            </li>
                            <li>
                                <a href="#"><small>Perbaharui Barang</small></a>
                            </li>
                            <li>
                                <a href="editDataPengguna.php"><small>Edit Data Diri</small></a>
                            </li>
                            <li>
                                <form action="action_testimoni.php" method="POST">
                                    <input class="form-control" type="text" placeholder="Tulis Testimoni - enter" id="testimoni" name="testimoni"/>
                                    <input type="hidden" id="id_pengguna" name="id_pengguna" value="<?php echo $t->getIdPengguna($status); ?>"/>
                                </form>                                
                            </li>
                        </ul>
                    </div>
                    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
                        <img src="img/logo.png" class="img-responsive im1"/>
                    </div>
                </div>
            </div>

            <div class="panel">
                <form action="hasilcari.php" method="POST">
                    <div class="row">
                        <div class="col-lg-12 col-md-12" style="width: 50%;padding-right: 0px;padding-right: 0px">
                            <input class="form-control" type="text" placeholder="Kata Kunci" name="katakunci"/>
                        </div>
                        <div class="col-lg-12 col-md-12" style="width: 20%;padding-left: 0px;padding-right: 0px">
                            <select class="form-control" name="kategori">
                                <option>Kategori</option>
                                <?php
                                for ($index2 = 0; $index2 < sizeof($t->tampilIDKategori()); $index2++) {
                                    ?>
                                    <option value="<?php echo $t->tampilIDKategori()[$index2] ?>"><?php echo $t->tampilKategori()[$index2] ?></option>
                                    <?php
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-lg-12 col-md-12" style="width: 20%;padding-left: 0px;padding-right: 0px">
                            <select class="form-control" name="provinsi">
                                <option>Provinsi</option>
                                <?php
                                for ($index3 = 0; $index3 < sizeof($t->tampilIdProvinsi()); $index3++) {
                                    ?>
                                    <option value="<?php echo $t->tampilIdProvinsi()[$index3] ?>"><?php echo $t->tampilProvinsi()[$index3] ?></option>
                                    <?php
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-lg-12 col-md-12" style="width: 9%;padding-left: 0px;padding-right: 0px">
                            <input type="submit" class="form-control btn btn-primary" value="CARI" name="cari"/>
                        </div>
                    </div>
                </form>
            </div>            
            <div class="panel panel-default panelKat">
                <?php
                $count = 0;
                $iftrue = 1;
                if (sizeof($t->TampilBarangPengguna($status)) > 0) {
                    for ($index = 0; $index < 20 && $iftrue == 1; $index++) {
                        ?><div class="row"><?php
                        for ($index1 = 0; $index1 < 4 && $iftrue == 1; $index1++) {
                            if ($count < sizeof($t->TampilBarangPengguna($status))) {
                                ?>                                    
                                    <div class="col-md-3 col-xs-12">
                                        <center>
                                            <div class="panel-body utama">
                                                <a href="deskripsiBarang.php?barang=<?php echo $t->TampilBarangPengguna($status)[$count] ?>"><img src="<?php echo $t->TampilUrlGambarBarang($t->TampilBarangPengguna($status)[$count]) ?>" class="img-thumbnail"/></a>
                                                <a href="deskripsiBarang.php?barang=<?php echo $t->TampilBarangPengguna($status)[$count] ?>"><b><center><?php echo $t->TampilNamaBarang($t->TampilBarangPengguna($status)[$count]) ?></center></b></a>
                                                <?php
                                                if ($status != '') {
                                                    ?>
                                                    <!--                                                <div class="row">
                                                                                                        <div class="col-md-5 col-xs-3">
                                                                                                            <h5 class="h5Like"><a href="#">Like  <span class="badge">200</span></a></h5>
                                                                                                        </div>
                                                                                                        <div class="col-md-7 col-xs-4">
                                                                                                            <h5 class="h5Comment"><a href="#">Comment  <span class="badge">150</span></a></h5>
                                                                                                        </div>
                                                                                                    </div>-->
<!--                                                    <br>
                                                    <ul class="list-group">
                                                        <li class="list-group-item"></li>
                                                        <li class="list-group-item"></li>
                                                        <li class="list-group-item"></li>
                                                        <li class="list-group-item"></li>
                                                    </ul>-->
                                                <?php }
                                                ?>
                                            </div>
                                        </center>
                                    </div>
                                    <?php
                                } else {
                                    $iftrue = 0;
                                }
                                $count++;
                            }
                            ?></div><?php
                    }
                } else {
                    ?>
                    <h2>Tidak ada barang</h2>
                    <?php
                }
                ?>
            </div>

            <div class="panel panel-default panelKat">
                <div class="panel-footer panelKaki">
                    <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <br><br><br>
                            <center><label class="fontKaki"><h4>@ Copyright 2014 semua berbagi - All right reserved</h4></label></center>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
